<template>
  <el-upload
    class="upload-demo"
    :action="$fileUpload"
    :headers="$headers"
    :data="{sceneCode:props.sceneCode}"
    :on-success="upSuccessHandler"
  >
    <el-button type="primary">上传文件</el-button>
  </el-upload>
</template>
<script lang="ts" setup>
import {ref, defineProps, defineEmits, reactive} from "vue";
import type { responseType } from "@/api/type";

let props = defineProps(["sceneCode"]);
let emits = defineEmits(["uploadFile"]);
export interface UpFileDTO{
  fileUrl:string,
  fileType:string
}
let upLoadFile=reactive<UpFileDTO>({
  fileUrl:'',
  fileType:'',
})

function upSuccessHandler(res: responseType<string>, file: any) {
  upLoadFile.fileType=file.raw.type
  upLoadFile.fileUrl=res.data.visitPath
  emits("uploadFile", upLoadFile);
}
</script>
